<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'table.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	  <script type="text/javascript" src="./jquery-2.1.1/jquery.js"></script>
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->

  </head>
  
  <body>

  <%
 
 System.out.println("current="+request.getAttribute("current"));
  System.out.println("pageCount="+request.getAttribute("pageCount"));
   System.out.println("count="+request.getAttribute("count"));
    System.out.println("pageSize="+request.getAttribute("pageSize"));
        System.out.println("data="+request.getAttribute("data"));
    Integer current=(Integer)request.getAttribute("current");//默认显示第一页
     Integer pageCount=(Integer)request.getAttribute("pageCount");//总页数
     Integer pageSize=(Integer)request.getAttribute("pageSize");//总页数
     Integer count=(Integer)request.getAttribute("count");//总页数
    List<Map<String,Object>> data=( ArrayList<Map<String,Object>>)request.getAttribute("data");
   

  %>
  <script type="text/javascript"></script>
    <table id="bbstable" border="1px">
    <tr><th>序号</th><th>帖子标题</th><th>作者</th><th>更新时间</th></tr>
     <%for(int i=0;i<data.size();i++){ %>
        <tr>
        
        <th><%=(i+1) %></th>
        <td class="td1"><%=data.get(i).get("title") %></td>
            <td class="td2"><%=data.get(i).get("auth") %></td>
            <td class="td3"><%=data.get(i).get("updatetime")%></td>
            </tr>
        <%
            }
        %>
    </table>
    <script type="text/javascript">
    $(function () {
        $(".td1").click(function () {
            console.log(this.innerHTML);
//            window.location.href="./tieziAction?title="+this.innerHTML;
            $.ajax({
                type: "GET",//1.type:get/post
                url: "./tiezi2Action?title="+this.innerHTML,
                dataType: "json",
                contentType:"application/json",
                success: function(data){

                    console.log("success");
                    console.log(data);

                    $("#info").html(data);
                },
                error: function(data){
                    console.log("error");
                      console.log(data);
                }
            });

        })
    })
    </script>
    <%
 
     %>
    <div><a href="#">首页</a>
    <%for(int i=0;i<pageCount;i++){ %>
    <a href="./fenyeAction?current=<%=i+1 %>"><%=i+1 %></a>
    <%} %>
    <a href="#">末页</a></div>
    <div id="info"></div>
    <script type="text/javascript">
    $(function () {

    })
    </script>
  </body>
</html>
